<?php

require("printFunc.inc.php");
require("dbFunc.inc.php");
require("sessFunc.inc.php");

verifySession();

if(!isset($_POST['searchtext']))
{
  header("Location: http://".$_SERVER['HTTP_HOST']
      .dirname($_SERVER['PHP_SELF'])."/error.php?errid=5");
}

if(strlen($_POST['searchtext'])>50)
{
  header("Location: http://".$_SERVER['HTTP_HOST']
      .dirname($_SERVER['PHP_SELF'])."/error.php?errid=6");
}

if(strlen($_POST['searchtext'])==0)
{
  header("Location: http://".$_SERVER['HTTP_HOST']
      .dirname($_SERVER['PHP_SELF'])."/index.php");
}

$searchString=$_POST['searchtext'];

$result = dbSearchContentString($searchString);

printHeader("Ricerca");
printLink();

?>
<div id="content">
<?

if (mysql_num_rows($result) > 0)
{

?>
    <h3><?echo mysql_num_rows($result);?> Risultati per la ricerca del termine: "<?echo $searchString;?>"</h3>
<?
   while($row=mysql_fetch_array($result))
   {
     $cat = dbGetCategoryName($row['categoria']);

     ?>
         <div class="catSearch">
         <a href="asta.php?idau=<?echo $row['id_asta'];?>"><h3><?echo $row['nome'];?></h3></a>
         Categoria: <a href="cat.php?idcat=<?echo $row['categoria'];?>"> <?echo $cat;?></a>
         <br/>
         <p><?echo $row['descrizione'];?></p>
         </div>
     <?
   }
}
else
{

?>
    <h3>Nessun risultato per la ricerca del termine: "<?echo $searchString;?>"</h3>
<?

}


?>

</div>

<? printFooter(); ?>